import { type RouteRecordRaw, createRouter, createWebHashHistory, createWebHistory } from "vue-router"

const Layout = () => import("@/layout/index.vue")
export const admin = "超级管理员"

/** 常驻路由 */
export const constantRoutes: RouteRecordRaw[] = [
  {
    path: "/redirect",
    component: Layout,
    meta: {
      hidden: true
    },
    children: [
      {
        path: "/redirect/:path(.*)",
        component: () => import("@/views/redirect/index.vue")
      }
    ]
  },
  {
    path: "/403",
    component: () => import("@/views/error-page/403.vue"),
    meta: {
      hidden: true
    }
  },
  {
    path: "/404",
    component: () => import("@/views/error-page/404.vue"),
    meta: {
      hidden: true
    },
    alias: "/:pathMatch(.*)*"
  },
  {
    path: "/login",
    component: () => import("@/views/login/index.vue"),
    meta: {
      hidden: true,
      title: "登录"
    }
  },
  {
    path: "/productDetil",
    component: () => import("@/views/productH5/index.vue"),
    meta: {
      hidden: true
    }
  },
  {
    path: "/productDetil2",
    component: () => import("@/views/productH5/index2.vue"),
    meta: {
      hidden: true
    }
  },
  {
    path: "/orderSearch",
    component: () => import("@/views/productH5/ordersearch.vue"),
    meta: {
      hidden: true
    }
  },
  {
    path: "/orderCreateYs",
    component: () => import("@/views/yunShang/orderCreateH5.vue"),
    meta: {
      hidden: true
    }
  },
  {
    path: "/stockOrder",
    component: () => import("@/views/stock-operation/stockOrderH5.vue"),
    meta: {
      hidden: true
    }
  },
  {
    path: "/stockOrderPreView",
    component: () => import("@/views/stock-operation/stockOrderH5Preview.vue"),
    meta: {
      hidden: true
    }
  },
  {
    path: "/orderCreateMp",
    component: () => import("@/views/multiport-xcx/orderCreateH5.vue"),
    meta: {
      hidden: true
    }
  },
  {
    path: "/h5List",
    component: () => import("@/views/productH5/list.vue"),
    meta: {
      hidden: true
    }
  },
  {
    path: "/h5OrderPut",
    component: () => import("@/views/productH5/share.vue"),
    meta: {
      hidden: true
    }
  },
  {
    path: "/advice",
    component: () => import("@/views/advice/index.vue"),
    meta: {
      hidden: true
    }
  },
  {
    path: "/adviceSearch",
    component: () => import("@/views/advice/myAdvice.vue"),
    meta: {
      hidden: true
    }
  },
  {
    path: "/hr/index",
    component: () => import("@/views/hrH5/index.vue"),
    meta: {
      hidden: true
    }
  },
  {
    path: "/hr/add",
    component: () => import("@/views/hrH5/add.vue"),
    meta: {
      hidden: true
    }
  },
  {
    path: "/hr/addS",
    component: () => import("@/views/hrH5/addschool.vue"),
    meta: {
      hidden: true
    }
  },
  {
    path: "/hr/list",
    component: () => import("@/views/hrH5/list.vue"),
    meta: {
      hidden: true
    }
  },
  {
    path: "/hr/listOwer",
    component: () => import("@/views/hrH5/listOwer.vue"),
    meta: {
      hidden: true
    }
  },
  {
    path: "/hr/details",
    component: () => import("@/views/hrH5/details.vue"),
    meta: {
      hidden: true
    }
  },
  {
    path: "/hr/search",
    component: () => import("@/views/hrH5/search.vue"),
    meta: {
      hidden: true
    }
  },
  {
    path: "/",
    component: Layout,
    redirect: "/dashboard",
    meta: {
      title: "首页"
    },
    children: [
      {
        path: "dashboard",
        component: () => import("@/views/dashboard/index.vue"),
        name: "Dashboard",
        meta: {
          title: "首页",
          svgIcon: "dashboard",
          affix: true
        }
      }
    ]
  },
  // {
  //   path: "/oneself",
  //   component: () => import("@/views/oneself/index2.vue"),
  //   meta: {
  //     hidden: true
  //   }
  // },
  {
    path: "/oneself",
    component: Layout,
    redirect: "/oneself",
    meta: { hidden: true, title: "个人中心" },
    children: [
      {
        path: "/oneself",
        component: () => import("@/views/oneself/index.vue"),
        name: "oneself",
        meta: {
          title: "个人中心"
        }
      }
    ]
  }
]

/**
 * 动态路由
 * 用来放置有权限 (Roles 属性) 的路由
 * 必须带有 Name 属性
 */
export const asyncRoutes: RouteRecordRaw[] = [
  {
    path: "/table",
    component: Layout,
    redirect: "/table/worker",
    name: "Worker",
    meta: {
      title: "员工管理",
      elIcon: "Grid",
      hidden: true,
      roles: [admin], // 可以在根路由中设置角色
      alwaysShow: true // 将始终显示根菜单
    },
    children: [
      {
        path: "worker",
        component: () => import("@/views/table/worker/index.vue"),
        name: "WorkerList",
        meta: {
          title: "人员列表",
          hidden: true,
          keepAlive: true,
          roles: [admin]
        }
      }
    ]
  },
  // 人事需求
  {
    path: "/personnel",
    redirect: "/personnel/personnel-list",
    name: "personnel",
    component: Layout,
    meta: {
      title: "人事管理",
      roles: [admin], // 可以在根路由中设置角色
      elIcon: "Avatar",
      hidden: true,
      alwaysShow: true // 将始终显示根菜单
    },
    children: [
      {
        path: "advice-list",
        component: () => import("@/views/advice/list.vue"),
        name: "adviceList",
        meta: {
          title: "公司信箱",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "personnel-list",
        component: () => import("@/views/personnel/personnel-list/index.vue"),
        name: "personnelList",
        meta: {
          title: "团队需求",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "personnel-children",
        component: () => import("@/views/personnel/personnel-children/index.vue"),
        name: "personneChildren",
        meta: {
          title: "人事",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "personnel-regulator",
        component: () => import("@/views/personnel/personnel-regulator/index.vue"),
        name: "personnelRegulator",
        meta: {
          title: "人事主管",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "regulator",
        component: () => import("@/views/personnel/regulator/index.vue"),
        name: "regulator",
        meta: {
          title: "管理员",
          keepAlive: true,
          roles: [admin]
        }
      }
    ]
  },
  // 部门团队
  {
    path: "/department",
    component: Layout,
    redirect: "/department/team",
    name: "Department",
    meta: {
      title: "部门团队",
      elIcon: "Trophy",
      roles: [admin],
      hidden: true,
      alwaysShow: true
    },
    children: [
      {
        path: "superior",
        component: () => import("@/views/table/superior/index.vue"),
        name: "superior",
        meta: {
          title: "部门管理",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "team",
        component: () => import("@/views/table/team/index.vue"),
        name: "teamList",
        meta: {
          title: "团队列表",
          keepAlive: true,
          roles: [admin]
        }
      },

      {
        path: "job-list",
        component: () => import("@/views/job/job-list/index.vue"),
        name: "JobList",
        meta: {
          title: "职位列表",
          keepAlive: true,
          roles: [admin]
        }
      },

      {
        path: "org-list",
        component: () => import("@/views/org/index.vue"),
        name: "OrgList",
        meta: {
          title: "组织架构",
          keepAlive: true,
          roles: [admin]
        }
      }
    ]
  },
  {
    path: "/combo-manage",
    redirect: "/combo-manage/combo-list",
    name: "CommboManage",
    component: Layout,
    meta: {
      title: "套餐管理",
      elIcon: "Shop",
      roles: [admin],
      alwaysShow: true
    },
    children: [
      {
        path: "combo-source",
        component: () => import("@/views/order/combo-source/index.vue"),
        name: "ComboSource",
        meta: {
          title: "套餐来源",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "combo-main",
        component: () => import("@/views/order/combo-list/main.vue"),
        name: "ComboMain",
        meta: {
          title: "主套餐",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "combo-list",
        component: () => import("@/views/order/combo-list/index.vue"),
        name: "ComboList",
        meta: {
          title: "套餐配置",
          // keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "product-list",
        component: () => import("@/views/order/product-list/index1.vue"),
        name: "ProductList",
        meta: {
          title: "产品列表",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "combo-compilation",
        component: () => import("@/views/order/combo-list/compilation.vue"),
        name: "Compilation",
        meta: {
          title: "套餐合集",
          keepAlive: true,
          hidden: false,
          roles: [admin]
        }
      },
      {
        path: "childset",
        component: () => import("@/views/order/combo-list/childSet.vue"),
        name: "childset",
        meta: {
          title: "套餐合集-子套餐",
          keepAlive: false,
          hidden: true,
          roles: [admin]
        }
      },
      {
        path: "provincesPro",
        component: () => import("@/views/order/combo-list/provincesPro.vue"),
        name: "provincesPro",
        meta: {
          title: "省内省外占比",
          keepAlive: false,
          hidden: false,
          roles: [admin]
        }
      }
    ]
  },
  {
    path: "/order-manage",
    redirect: "/order-manage/order-list",
    name: "OrderManage",
    component: Layout,
    meta: {
      title: "订单管理",
      // svgIcon: "lock",
      elIcon: "Tickets",
      roles: [admin], // 可以在根路由中设置角色
      alwaysShow: true // 将始终显示根菜单
    },
    children: [
      {
        path: "order-list",
        component: () => import("@/views/order/order-list/index.vue"),
        name: "OrderList",
        meta: {
          title: "订单列表",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "order-list-x",
        component: () => import("@/views/order/order-list-x/index.vue"),
        name: "OrderListX",
        meta: {
          title: "订单修改",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "order-list-ls",
        component: () => import("@/views/order/order-list-ls/index.vue"),
        name: "OrderListLs",
        meta: {
          title: "历史订单数据",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "dylive",
        component: () => import("@/views/order/dylive/index.vue"),
        name: "DyLive",
        meta: {
          title: "抖音直播间配置",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "grapOrderSet",
        component: () => import("@/views/order/ips/index.vue"),
        name: "grapOrderSet",
        meta: {
          title: "0点抢单设置",
          keepAlive: true,
          roles: [admin]
        }
      }
    ]
  },
  {
    path: "/webset-manage",
    redirect: "/webset-manage/order-list",
    name: "WebSetManage",
    component: Layout,
    meta: {
      title: "宽带业务",
      // svgIcon: "lock",
      elIcon: "SetUp",
      roles: [admin], // 可以在根路由中设置角色
      alwaysShow: true // 将始终显示根菜单
    },
    children: [
      {
        path: "super-set",
        component: () => import("@/views/webset/super.vue"),
        name: "WebSuperSet",
        meta: {
          title: "上级配置",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "product-set",
        component: () => import("@/views/webset/product.vue"),
        name: "WebProductSet",
        meta: {
          title: "宽带产品配置",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "order-list",
        component: () => import("@/views/webset/index.vue"),
        name: "WebList",
        meta: {
          title: "宽带订单列表",
          keepAlive: true,
          roles: [admin]
        }
      }
    ]
  },
  // 收支模块
  {
    path: "/SZ",
    redirect: "/SZ/revenue-dr",
    name: "SZ",
    component: Layout,
    meta: {
      title: "收支业务",
      // svgIcon: "lock",
      elIcon: "SetUp",
      roles: [admin], // 可以在根路由中设置角色
      alwaysShow: true // 将始终显示根菜单
    },
    children: [
      {
        path: "SzGeneral",
        component: () => import("@/views/SZ/SzGeneral/index.vue"),
        name: "SzGeneral",
        meta: {
          title: "收支表-通用版",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "revenue-dr",
        component: () => import("@/views/SZ/revenueDr/index.vue"),
        name: "revenueDr",
        meta: {
          title: "导入列表",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "SZXxfy",
        component: () => import("@/views/SZ/SZXxfy/index.vue"),
        name: "SZXxfy",
        meta: {
          title: "线下费用",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "SZHdfy",
        component: () => import("@/views/SZ/SZHdfy/index.vue"),
        name: "SZHdfy",
        meta: {
          title: "活动费用",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "SZBouns",
        component: () => import("@/views/SZ/bonus/index.vue"),
        name: "SZBouns",
        meta: {
          title: "奖金系数",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "SZLrtable",
        component: () => import("@/views/SZ/SZLrtable/index.vue"),
        name: "SZLrtable",
        meta: {
          title: "利润表",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "dayNumber",
        component: () => import("@/views/SZ/dayNumber/index.vue"),
        name: "dayNumber",
        meta: {
          title: "单日人数",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "peopleExpen",
        component: () => import("@/views/SZ/peopleExpen/index.vue"),
        name: "peopleExpen",
        meta: {
          title: "单人支出",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "JDdevoted",
        component: () => import("@/views/SZ/JDdevoted/index.vue"),
        name: "JDdevoted",
        meta: {
          title: "京东专用",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "PDdevoted",
        component: () => import("@/views/SZ/PDdevoted/index.vue"),
        name: "PDdevoted",
        meta: {
          title: "拼多专用",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "ztTable",
        component: () => import("@/views/SZ/ztTable/index.vue"),
        name: "ztTable",
        meta: {
          title: "状态表",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "numberCard",
        component: () => import("@/views/SZ/numberCard/index.vue"),
        name: "numberCard",
        meta: {
          title: "号卡销量",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "broadBand",
        component: () => import("@/views/SZ/broadBand/index.vue"),
        name: "broadBand",
        meta: {
          title: "宽带销量",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "personal",
        component: () => import("@/views/SZ/personal/index.vue"),
        name: "personal",
        meta: {
          title: "个人功能",
          keepAlive: true,
          roles: [admin]
        }
      },

      {
        path: "ShippingAct",
        component: () => import("@/views/SZ/ShippingAct/index.vue"),
        name: "ShippingAct",
        meta: {
          title: "发货激活表(明细)",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "shopSales",
        component: () => import("@/views/SZ/shopSales/index.vue"),
        name: "shopSales",
        meta: {
          title: "店铺销量表(汇总)",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "settlement",
        component: () => import("@/views/SZ/settlement/index.vue"),
        name: "settlement",
        meta: {
          title: "结算表",
          keepAlive: true,
          roles: [admin]
        }
      }
    ]
  },
  //存量业务相关
  {
    path: "/stock-manage",
    redirect: "/stock-manage/order",
    name: "StockManage",
    component: Layout,
    meta: {
      title: "存量业务",
      elIcon: "Histogram",
      roles: [admin],
      hidden: true,
      alwaysShow: true
    },
    children: [
      {
        path: "source",
        component: () => import("@/views/stock-operation/source.vue"),
        name: "StockSource",
        meta: {
          title: "上级来源",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "order",
        component: () => import("@/views/stock-operation/order.vue"),
        name: "OrderStockH5",
        meta: {
          title: "存量订单",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "combo-set",
        component: () => import("@/views/stock-operation/comboSet.vue"),
        name: "ComboStockList",
        meta: {
          title: "存量套餐",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "share",
        component: () => import("@/views/stock-operation/share.vue"),
        name: "StockShare",
        meta: {
          title: "产品分享",
          keepAlive: true,
          roles: [admin]
        }
      }
    ]
  },
  {
    path: "/xinghai",
    redirect: "/xinghai/shop",
    name: "XingHai",
    component: Layout,
    meta: {
      title: "星海",
      // svgIcon: "lock",
      elIcon: "StarFilled",
      hidden: true,
      roles: [admin], // 可以在根路由中设置角色
      alwaysShow: true // 将始终显示根菜单
    },
    children: [
      {
        path: "shop",
        component: () => import("@/views/xinghai/shop.vue"),
        name: "XingHaiShop",
        meta: {
          title: "店铺配置",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "pool",
        component: () => import("@/views/xinghai/pool.vue"),
        name: "XingHaiPool",
        meta: {
          title: "号池配置",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "Xhphone",
        component: () => import("@/views/xinghai/phone.vue"),
        name: "XingHaiPhone",
        meta: {
          title: "号码搜索",
          keepAlive: true,
          roles: [admin]
        }
      }
    ]
  },
  {
    path: "/outbound",
    redirect: "/outbound/outbound-list",
    name: "outBound",
    component: Layout,
    meta: {
      title: "外呼管理",
      // svgIcon: "lock",
      elIcon: "PhoneFilled",
      hidden: true,
      roles: [admin], // 可以在根路由中设置角色
      alwaysShow: true // 将始终显示根菜单
    },
    children: [
      {
        path: "outbound-admin-list",
        component: () => import("@/views/outbound/outbound-admin-list/index.vue"),
        name: "outboundAdminList",
        meta: {
          title: "管理列表",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "outbound-list",
        component: () => import("@/views/outbound/outbound-list/index.vue"),
        name: "outboundList",
        meta: {
          title: "任务列表",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "outbound-callout",
        component: () => import("@/views/outbound/outbound-callout/index.vue"),
        name: "outboundcallout",
        meta: {
          title: "呼叫记录",
          keepAlive: true,
          roles: [admin]
        }
      }
    ]
  },
  // pdd
  {
    path: "/capture-order",
    redirect: "/capture-order/capture-list",
    name: "CaptureOrder",
    component: Layout,
    meta: {
      title: "拼多多抓单管理",
      // svgIcon: "lock",
      // elIcon: Trophy,
      hidden: true,
      elThirdIcon: "el-icon-thirdpinduoduo", // elIcon 饿了么自带图标字体    elThirdIcon 第三方iconfont阿里图标字体库
      roles: [admin], // 可以在根路由中设置角色
      alwaysShow: true // 将始终显示根菜单
    },
    children: [
      {
        path: "setting-pdd",
        component: () => import("@/views/capture/pdd/setting.vue"),
        name: "SettingPdd",
        meta: {
          title: "店铺配置",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "combo-select-pdd",
        component: () => import("@/views/capture/pdd/taocan.vue"),
        name: "ComboSelectPdd",
        meta: {
          title: "套餐匹配",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "capture-list",
        component: () => import("@/views/capture/pdd/index.vue"),
        name: "CaptureList",
        meta: {
          title: "订单列表",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "capture-list-plus",
        component: () => import("@/views/capture/pdd/indexPlus.vue"),
        name: "CaptureListPlus",
        meta: {
          title: "订单列表2.0",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "push-record-list",
        component: () => import("@/views/capture/pdd/pushRecord.vue"),
        name: "PushRecordList",
        meta: {
          title: "提交记录",
          keepAlive: true,
          roles: [admin]
        }
      }
    ]
  },
  // jd
  {
    path: "/capture-jd-order",
    redirect: "/capture-jd-order/capture-list",
    name: "CaptureOrder-jd",
    component: Layout,
    meta: {
      title: "京东抓单管理",
      // svgIcon: "lock",
      // elIcon: Trophy,
      hidden: true,
      elThirdIcon: "el-icon-thirdjingdong_", // elIcon 饿了么自带图标字体    elThirdIcon 第三方iconfont阿里图标字体库
      roles: [admin], // 可以在根路由中设置角色
      alwaysShow: true // 将始终显示根菜单
    },
    children: [
      {
        path: "setmeal",
        component: () => import("@/views/capture/jd/taocan.vue"),
        name: "setmeal",
        meta: {
          title: "套餐匹配",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "capture-list2",
        component: () => import("@/views/capture/jd/index2.vue"),
        name: "CaptureListJd2",
        meta: {
          title: "订单列表(旧版)",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "capture-list",
        component: () => import("@/views/capture/jd/index.vue"),
        name: "CaptureListJd",
        meta: {
          title: "订单列表(新版)",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "setting",
        component: () => import("@/views/capture/jd/setting.vue"),
        name: "setting",
        meta: {
          title: "店铺设置",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "setting-jd-pre",
        component: () => import("@/views/capture/jd/preCalibration.vue"),
        name: "SettingJDPre",
        meta: {
          title: "前置校验",
          // hidden: true,
          keepAlive: true,
          roles: [admin]
        }
      }
    ]
  },
  // 抖音
  {
    path: "/capture-dy",
    redirect: "/capture-dy/capture-list-dy",
    name: "CaptureDy",
    component: Layout,
    meta: {
      title: "抖音抓单管理",
      hidden: true,
      // svgIcon: "lock",
      // elIcon: Trophy,
      elThirdIcon: "el-icon-thirdicon_douyin", // elIcon 饿了么自带图标字体    elThirdIcon 第三方iconfont阿里图标字体库
      roles: [admin], // 可以在根路由中设置角色
      alwaysShow: true // 将始终显示根菜单
    },
    children: [
      {
        path: "combo-select-dy",
        component: () => import("@/views/capture/dy/taocan.vue"),
        name: "ComboSelectDy",
        meta: {
          title: "套餐匹配",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "capture-list-dy",
        component: () => import("@/views/capture/dy/index.vue"),
        name: "CaptureListDy",
        meta: {
          title: "订单列表",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "capture-list-dy2",
        component: () => import("@/views/capture/dy/index2.vue"),
        name: "CaptureListDy2",
        meta: {
          title: "订单留存",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "setting-dy",
        component: () => import("@/views/capture/dy/setting.vue"),
        name: "SettingDy",
        meta: {
          title: "店铺设置",
          keepAlive: true,
          roles: [admin]
        }
      }
    ]
  },
  // 淘宝
  {
    path: "/capture-tb-order",
    redirect: "/capture-tb-order/capture-list-tb",
    name: "CaptureOrderTb",
    component: Layout,
    meta: {
      title: "淘宝抓单管理",
      hidden: true,
      // svgIcon: "lock",
      // elIcon: Trophy,
      // hidden: true,
      elThirdIcon: "el-icon-thirdtaobao_", // elIcon 饿了么自带图标字体    elThirdIcon 第三方iconfont阿里图标字体库
      roles: [admin], // 可以在根路由中设置角色
      alwaysShow: true // 将始终显示根菜单
    },
    children: [
      {
        path: "setmeal-tb",
        component: () => import("@/views/capture/tb/taocan.vue"),
        name: "ComboTb",
        meta: {
          title: "套餐匹配",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "capture-list-tb",
        component: () => import("@/views/capture/tb/index.vue"),
        name: "CaptureListTb",
        meta: {
          title: "订单列表",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "capture-list-tb2",
        component: () => import("@/views/capture/tb/index2.vue"),
        name: "CaptureListTb2",
        meta: {
          title: "订单留存",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "setting-tb",
        component: () => import("@/views/capture/tb/setting.vue"),
        name: "SettingTb",
        meta: {
          title: "店铺设置",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "setting-tb-pre",
        component: () => import("@/views/capture/tb/preCalibration.vue"),
        name: "SettingPre",
        meta: {
          title: "前置校验",
          // hidden: true,
          keepAlive: true,
          roles: [admin]
        }
      }
    ]
  },
  //H5相关
  {
    path: "/h5-manage",
    redirect: "/h5-manage/order-list-h5",
    name: "H5Manage",
    component: Layout,
    meta: {
      title: "H5管理",
      elIcon: "Cellphone",
      roles: [admin],
      alwaysShow: true
    },
    children: [
      {
        path: "order-list-h5",
        component: () => import("@/views/order/orderH5/index.vue"),
        name: "OrderListH5",
        meta: {
          title: "H5订单",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "combo-h5-list",
        component: () => import("@/views/combo-h5/index.vue"),
        name: "ComboH5List",
        meta: {
          title: "H5套餐",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "product-share",
        component: () => import("@/views/combo-h5/share.vue"),
        name: "ProductShare",
        meta: {
          title: "产品分享",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "combo-collection",
        component: () => import("@/views/combo-h5/collection.vue"),
        name: "ComboCollection",
        meta: {
          title: "自定义H5列表",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "childset",
        component: () => import("@/views/combo-h5/childSet.vue"),
        name: "ComboChildset",
        meta: {
          title: "子套餐",
          keepAlive: true,
          hidden: true,
          roles: [admin]
        }
      },
      {
        path: "combo-recommend",
        component: () => import("@/views/combo-h5/recommend.vue"),
        name: "ComboRecommend",
        meta: {
          title: "H5推荐套餐",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "childsetRecom",
        component: () => import("@/views/combo-h5/childSetRecom.vue"),
        name: "ChildsetRecom",
        meta: {
          title: "子套餐",
          keepAlive: true,
          hidden: true,
          roles: [admin]
        }
      }
    ]
  },

  //小程序相关
  {
    path: "/xcx-manage",
    redirect: "/xcx-manage/xcx-duoduan",
    name: "XcxManage",
    component: Layout,
    meta: {
      title: "小程序管理",
      elIcon: "Iphone",
      hidden: true,
      roles: [admin],
      alwaysShow: true
    },
    children: [
      // {
      //   path: "xcx-order",
      //   component: () => import("@/views/combo-xcx/list.vue"),
      //   name: "XcxOrder",
      //   meta: {
      //     title: "小程序订单",
      //     keepAlive: true,
      //     roles: [admin],
      //     hidden: true
      //   }
      // },
      // {
      //   path: "xcx-list",
      //   component: () => import("@/views/combo-xcx/index2.vue"),
      //   name: "ComboXcxList",
      //   meta: {
      //     title: "5G号卡套餐",
      //     keepAlive: true,
      //     roles: [admin],
      //     hidden: true
      //   }
      // },
      {
        path: "xcx-platform",
        component: () => import("@/views/applet/index.vue"),
        name: "XcxPlatform",
        meta: {
          title: "小程序平台",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "xcx-settings",
        component: () => import("@/views/applet/settings.vue"),
        name: "XcxSettings",
        meta: {
          title: "团队绑定",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "xcx-banners",
        component: () => import("@/views/applet/banner.vue"),
        name: "XcxBanners",
        meta: {
          title: "轮播图配置",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "xcx-duoduan",
        component: () => import("@/views/combo-xcx/duoduan.vue"),
        name: "ComboXcxduoduan",
        meta: {
          title: "产品套餐",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "xcx-ms-order",
        component: () => import("@/views/multiport-xcx/index.vue"),
        name: "XcxMsOrder",
        meta: {
          title: "订单列表",
          keepAlive: true,
          roles: [admin]
        }
      }
      // {
      //   path: "configurationRule",
      //   component: () => import("@/views/distribution/configurationRule/index2.vue"),
      //   name: "configurationRule",
      //   meta: {
      //     title: "配置规则",
      //     keepAlive: true,
      //     hidden: true,
      //     roles: [admin]
      //   }
      // }
    ]
  },
  {
    path: "/xcxYs-manage",
    redirect: "/xcxYs-manage/xcxYs-list",
    name: "XcxYsManage",
    component: Layout,
    meta: {
      title: "云尚号卡",
      elIcon: "UploadFilled",
      roles: [admin],
      hidden: true,
      alwaysShow: true
    },
    children: [
      {
        path: "xcxYs-list",
        component: () => import("@/views/yunShang/index.vue"),
        name: "XcxYsList",
        meta: {
          title: "云尚产品",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "xcxYs-order",
        component: () => import("@/views/yunShang/list.vue"),
        name: "XcxYsOrder",
        meta: {
          title: "订单",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "xcxYs-user",
        component: () => import("@/views/yunShang/user.vue"),
        name: "XcxYsUser",
        meta: {
          title: "代理列表",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "xcxYs-setting",
        component: () => import("@/views/yunShang/setting.vue"),
        name: "XcxYsSetting",
        meta: {
          title: "配置规则",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "xcxYs-settle",
        component: () => import("@/views/yunShang/settlement.vue"),
        name: "XcxYsSettle",
        meta: {
          title: "佣金结算",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "xcxYs-moneyTX",
        component: () => import("@/views/yunShang/moneyTx.vue"),
        name: "XcxYsmoneyTX",
        meta: {
          title: "提现审批",
          keepAlive: true,
          roles: [admin]
        }
      }
    ]
  },
  // 充值缴费
  {
    path: "/vouchercenter",
    component: Layout,
    redirect: "/vouchercenter/telephone",
    name: "vouchercenter",
    meta: {
      title: "充值管理",
      elIcon: "ShoppingCart",
      roles: [admin],
      alwaysShow: true
    },

    children: [
      {
        path: "telephone",
        component: () => import("@/views/vouchercenter/telephone/index.vue"),
        name: "telephone",
        meta: {
          title: "话费充值",
          keepAlive: true,
          roles: [admin]
        }
      },
      // setting
      {
        path: "configuration",
        component: () => import("@/views/vouchercenter/configuration/index.vue"),
        name: "configuration",
        meta: {
          title: "充值配置",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "rechargeRecord",
        component: () => import("@/views/vouchercenter/rechargeRecord/index.vue"),
        name: "rechargeRecord",
        meta: {
          title: "充值记录",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "transactionDetail",
        component: () => import("@/views/vouchercenter/transactionDetail/index.vue"),
        name: "transactionDetail",
        meta: {
          title: "交易明细",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "search",
        component: () => import("@/views/vouchercenter/search/index.vue"),
        name: "SearchRich",
        meta: {
          title: "财务查询",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "approvalProcess",
        component: () => import("@/views/vouchercenter/approvalProcess/index.vue"),
        name: "approvalProcess",
        meta: {
          title: "自推佣金审批",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "recommend",
        component: () => import("@/views/vouchercenter/recommend/index.vue"),
        name: "recommend",
        meta: {
          title: "推广佣金审批",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "upup",
        component: () => import("@/views/vouchercenter/upup/index.vue"),
        name: "upup",
        meta: {
          title: "激励佣金审批",
          keepAlive: true,
          roles: [admin]
        }
      }
    ]
  },

  // 订单投诉
  {
    path: "/complaint",
    component: Layout,
    redirect: "/complaint/publish",
    name: "complaint",
    meta: {
      title: "订单投诉",
      elIcon: "Files",
      roles: [admin],
      alwaysShow: true
    },
    children: [
      {
        path: "publish",
        component: () => import("@/views/complaint/publish/index.vue"),
        name: "Publish",
        meta: {
          title: "投诉发布",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "dispose",
        component: () => import("@/views/complaint/dispose/index.vue"),
        name: "Dispose",
        meta: {
          title: "投诉处理",
          roles: [admin]
        }
      }
    ]
  },
  // 工单投诉
  {
    path: "/complaint/workOrder",
    component: Layout,
    redirect: "/complaint/workOrder/workOrder-one",
    name: "workOrder",
    meta: {
      title: "工单处理",
      elIcon: "Files",
      roles: [admin],
      alwaysShow: true
    },
    children: [
      {
        path: "workOrder-one",
        component: () => import("@/views/complaint/workOrder/one/index.vue"),
        name: "WorkOrderOne",
        meta: {
          title: "店长审批",
          roles: [admin]
        }
      },
      {
        path: "workOrder-two",
        component: () => import("@/views/complaint/workOrder/two/index.vue"),
        name: "WorkOrderTwo",
        meta: {
          title: "运营审批",
          roles: [admin]
        }
      },
      {
        path: "workOrder-three",
        component: () => import("@/views/complaint/workOrder/three/index.vue"),
        name: "WorkOrderThree",
        meta: {
          title: "部门经理审批",
          roles: [admin]
        }
      },
      {
        path: "workOrder-four",
        component: () => import("@/views/complaint/workOrder/four/index.vue"),
        name: "WorkOrderFour",
        meta: {
          title: "公司审批",
          roles: [admin]
        }
      },
      {
        path: "workOrder-five",
        component: () => import("@/views/complaint/workOrder/five/index.vue"),
        name: "WorkOrderFive",
        meta: {
          title: "申诉审批",
          roles: [admin]
        }
      }
    ]
  },

  // 发送短信
  {
    path: "/shortNote",
    component: Layout,
    redirect: "/shortNote/Addnote",
    name: "shortNote",
    meta: {
      title: "短信管理",
      elIcon: "Message",
      roles: [admin],
      alwaysShow: true
    },
    children: [
      {
        path: "msg-interface-set",
        component: () => import("@/views/shortNote/interfaceSet/index.vue"),
        name: "MsgInterFaceSet",
        meta: {
          title: "签名接口",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "msg-sign",
        component: () => import("@/views/shortNote/sign/index.vue"),
        name: "MsgSign",
        meta: {
          title: "短信签名",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "msg-tmp",
        component: () => import("@/views/shortNote/template/index.vue"),
        name: "MsgTmp",
        meta: {
          title: "短信模板",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "Addnote",
        component: () => import("@/views/shortNote/Addnote/index.vue"),
        name: "Addnote",
        meta: {
          title: "发送短信",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        // 发送记录 SendingRecord
        path: "SendingRecord",
        component: () => import("@/views/shortNote/SendingRecord/index.vue"),
        name: "SendingRecord",
        meta: {
          title: "数据统计",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        // 短连接 Shortlink
        path: "Shortlink",
        component: () => import("@/views/shortNote/Shortlink/index.vue"),
        name: "ShortLink",
        meta: {
          title: "短链生成",
          keepAlive: true,
          roles: [admin]
        }
      }
    ]
  },
  // 分销管理
  {
    path: "/distribution",
    component: Layout,
    redirect: "/distribution/agency",
    name: "distribution",
    meta: {
      title: "分销管理",
      elIcon: "Share",
      roles: [admin],
      alwaysShow: true
    },
    children: [
      {
        path: "agency",
        component: () => import("@/views/distribution/agency/index.vue"),
        name: "Agency",
        meta: {
          title: "分销代理",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "distribution-order",
        component: () => import("@/views/distribution/order/index.vue"),
        name: "DistributionOrder",
        meta: {
          title: "分销订单",
          keepAlive: true,
          roles: [admin]
        }
      }
      // {
      //   path: "relation",
      //   component: () => import("@/views/distribution/relation/index2.vue"),
      //   name: "relation",
      //   meta: {
      //     title: "分销关系",
      //     // keepAlive: true,
      //     roles: [admin]
      //   }
      // },
      // configurationRule
    ]
  },
  // 风控中心
  {
    path: "/RiskControlCenter",
    component: Layout,
    redirect: "/RiskControlCenter/user",
    name: "RiskControlCenter",
    meta: {
      title: "风控中心",
      elIcon: "CloseBold",
      roles: [admin],
      alwaysShow: true
    },
    children: [
      {
        path: "user",
        component: () => import("@/views/RiskControlCenter/user/index.vue"),
        name: "FkUser",
        meta: {
          title: "风控用户",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "RiskControlCenter-order",
        component: () => import("@/views/RiskControlCenter/order/index.vue"),
        name: "RiskControlCenterOrder",
        meta: {
          title: "拦截订单",
          keepAlive: true,
          roles: [admin]
        }
      }
    ]
  },
  // 财务模块
  // {
  //   path: "/finance",
  //   component: Layout,
  //   redirect: "/finance/cooperator",
  //   name: "finance",
  //   meta: {
  //     title: "财务中心",
  //     elIcon: "OfficeBuilding",
  //     roles: [admin],
  //     alwaysShow: true
  //   },
  //   children: [
  //     {
  //       path: "cooperator",
  //       component: () => import("@/views/finance/cooperator/index2.vue"),
  //       name: "cooperator",
  //       meta: {
  //         title: "合作伙伴",
  //         // keepAlive: true,
  //         roles: [admin]
  //       }
  //     },
  //     {
  //       path: "basics",
  //       component: () => import("@/views/finance/basics/index2.vue"),
  //       name: "basics",
  //       meta: {
  //         title: "公司信息",
  //         // keepAlive: true,
  //         roles: [admin]
  //       }
  //     },
  //     {
  //       path: "store",
  //       component: () => import("@/views/finance/store/index2.vue"),
  //       name: "store",
  //       meta: {
  //         title: "财务资料",
  //         keepAlive: true,
  //         // keepAlive: true,
  //         roles: [admin]
  //       }
  //     }
  //   ]
  // },
  // 操作日志
  {
    path: "/operationLog",
    component: Layout,
    redirect: "/operationLog/order",
    name: "operationLog",
    meta: {
      title: "操作日志",
      elIcon: "Notebook",
      roles: [admin],
      alwaysShow: true
    },
    children: [
      {
        path: "order",
        component: () => import("@/views/operationLog/order/index.vue"),
        name: "LogOrder",
        meta: {
          title: "日志列表",
          keepAlive: true,
          roles: [admin]
        }
      }
      // {
      //   path: "taocan",
      //   component: () => import("@/views/operationLog/taocan/index2.vue"),
      //   name: "taocan",
      //   meta: {
      //     title: "套餐日志",
      //     // keepAlive: true,
      //     roles: [admin]
      //   }
      // }
    ]
  },
  // 知识库
  {
    path: "/repository",
    component: Layout,
    redirect: "/repository/postRepository",
    name: "repository",
    meta: {
      title: "知识库",
      elIcon: "Notebook",
      roles: [admin],
      alwaysShow: true
    },
    children: [
      {
        path: "postRepository",
        component: () => import("@/views/repository/postRepository/index.vue"),
        name: "PostRepository",
        meta: {
          title: "岗位知识库",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "synthesizeRepository",
        component: () => import("@/views/repository/synthesizeRepository/index.vue"),
        name: "SynthesizeRepository",
        meta: {
          title: "综合知识库",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "rewardsORpunishments",
        component: () => import("@/views/repository/rewardsORpunishments/index.vue"),
        name: "rewardsORpunishments",
        meta: {
          title: "奖惩中心",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "classificationRepository",
        component: () => import("@/views/repository/classificationRepository/index.vue"),
        name: "ClassificationRepository",
        meta: {
          title: "知识库分类",
          keepAlive: true,
          roles: [admin]
        }
      },

      {
        path: "askRepository",
        component: () => import("@/views/repository/askRepository/index.vue"),
        name: "AskRepository",
        meta: {
          title: "问答专区",
          keepAlive: true,
          roles: [admin]
        }
      }
    ]
  },
  // 权限
  {
    path: "/role",
    component: Layout,
    redirect: "/role/role-list",
    name: "Role",
    meta: {
      title: "权限管理",
      svgIcon: "lock",
      roles: [admin], // 可以在根路由中设置角色
      alwaysShow: true // 将始终显示根菜单
    },
    children: [
      {
        path: "role-list",
        component: () => import("@/views/role/role-list/index.vue"),
        name: "RoleList",
        meta: {
          title: "权限列表",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "ban-list",
        component: () => import("@/views/role/ban/index.vue"),
        name: "BanList",
        meta: {
          title: "维护页面",
          keepAlive: true,
          roles: [admin]
        }
      }
    ]
  },
  {
    path: "/user",
    component: Layout,
    redirect: "/user/user-list",
    name: "User",
    meta: {
      title: "账号管理",
      elIcon: "Platform",
      roles: [admin], // 可以在根路由中设置角色
      alwaysShow: true // 将始终显示根菜单
    },
    children: [
      {
        path: "user-list",
        component: () => import("@/views/user/user-list/index.vue"),
        name: "userList",
        meta: {
          title: "账号列表",
          keepAlive: true,
          roles: [admin]
        }
      },
      {
        path: "addMoney",
        component: () => import("@/views/user/addMoney/index.vue"),
        name: "addMoney",
        meta: {
          title: "账号加款",
          keepAlive: true,
          roles: [admin]
        }
      }
    ]
  },
  {
    path: "/:pathMatch(.*)*", // Must put the 'ErrorPage' route at the end, 必须将 'ErrorPage' 路由放在最后
    redirect: "/404",
    name: "ErrorPage",
    meta: {
      hidden: true
    }
  }
]

const router = createRouter({
  history:
    import.meta.env.VITE_ROUTER_HISTORY === "hash"
      ? createWebHashHistory(import.meta.env.VITE_PUBLIC_PATH)
      : createWebHistory(import.meta.env.VITE_PUBLIC_PATH),
  routes: constantRoutes
})

/** 重置路由 */
export function resetRouter() {
  // 注意：所有动态路由路由必须带有 Name 属性，否则可能会不能完全重置干净
  try {
    router.getRoutes().forEach((route) => {
      const { name, meta } = route
      if (name && meta.roles?.length) {
        router.hasRoute(name) && router.removeRoute(name)
      }
    })
  } catch (error) {
    // 强制刷新浏览器也行，只是交互体验不是很好
    window.location.reload()
  }
}

export default router
